﻿using System;
namespace Producers.Liiklusregister.Xtee.Riik.Ee.Producer.Liiklusregister {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="vlaevRequest", Namespace="http://producers.liiklusregister.xtee.riik.ee/producer/liiklusregister", Target=typeof(VlaevRequest))]
    public class VlaevRequestSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IVlaevRequest clazz;
        
        public VlaevRequestSerializer(IVlaevRequest clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("laeva_regnr");
            if (clazz.LaevaRegnr!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.LaevaRegnr))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : LaevaRegnr");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("hin_kood");
            if (clazz.HinKood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.HinKood))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : HinKood");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("oma_andmed");
            if (clazz.OmaAndmed!=null) {
                global::Xtee.Core.SerializationMetadata metaOmaAndmed = this.GetMetaData(clazz.OmaAndmed);
                Writer.WriteTypeAttribute(metaOmaAndmed.TypeQualifiedName.Namespace, metaOmaAndmed.TypeQualifiedName.Name);
                metaOmaAndmed.NewSerializer(clazz.OmaAndmed).WriteXml(Writer);
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : OmaAndmed");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
        START:
            if ((Reader.LocalName == "laeva_regnr")) {
                goto laeva_regnr;
            }
            else {
                if ((Reader.LocalName == "hin_kood")) {
                    goto hin_kood;
                }
                else {
                    if ((Reader.LocalName == "oma_andmed")) {
                        goto oma_andmed;
                    }
                    else {
                        return;
                    }
                }
            }
        laeva_regnr:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>vlaevRequest>laeva_regnr");
            }
            clazz.LaevaRegnr = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("laeva_regnr")).Value;
            goto START;
        hin_kood:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>vlaevRequest>hin_kood");
            }
            clazz.HinKood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("hin_kood")).Value;
            goto START;
        oma_andmed:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>vlaevRequest>oma_andmed");
            }
            global::Xtee.Core.SerializationMetadata metaOmaAndmed = this.GetMetaData<VlaevRequest.IOmaAndmedType>(Reader, ">>vlaevRequest>oma_andmed", "http://producers.liiklusregister.xtee.riik.ee/producer/liiklusregister");
            clazz.OmaAndmed = metaOmaAndmed.NewEntity<VlaevRequest.IOmaAndmedType>();
            if ((Reader.IsEmptyElement == false)) {
                Reader.ReadStartElement("oma_andmed");
                metaOmaAndmed.NewSerializer(clazz.OmaAndmed).ReadXml(Reader);
                Reader.ReadEndElement();
            }
            else {
                Reader.Skip();
            }
            goto START;
        }
        
        [global::Xtee.Core.Attributes.XmlTypeAttribute(Name=">>vlaevRequest>oma_andmed", Namespace="http://producers.liiklusregister.xtee.riik.ee/producer/liiklusregister", Target=typeof(VlaevRequest.OmaAndmedType))]
        public class OmaAndmedTypeSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
            
            protected VlaevRequest.IOmaAndmedType clazz;
            
            public OmaAndmedTypeSerializer(VlaevRequest.IOmaAndmedType clazz) {
                this.clazz = clazz;
            }
            
            public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
                base.WriteXml(Writer);
                Writer.WriteStartElement("oma_kood");
                if (clazz.OmaKood!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.OmaKood))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : OmaKood");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("oma_nimi");
                if (clazz.OmaNimi!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.OmaNimi))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : OmaNimi");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("oma_eesnimi");
                if (clazz.OmaEesnimi!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.OmaEesnimi))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : OmaEesnimi");
                }
                Writer.WriteEndElement();
            }
            
            public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
                base.ReadXml(Reader);
            START:
                if ((Reader.LocalName == "oma_kood")) {
                    goto oma_kood;
                }
                else {
                    if ((Reader.LocalName == "oma_nimi")) {
                        goto oma_nimi;
                    }
                    else {
                        if ((Reader.LocalName == "oma_eesnimi")) {
                            goto oma_eesnimi;
                        }
                        else {
                            return;
                        }
                    }
                }
            oma_kood:
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>vlaevRequest>oma_andmed>oma_kood");
                }
                clazz.OmaKood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("oma_kood")).Value;
                goto START;
            oma_nimi:
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>vlaevRequest>oma_andmed>oma_nimi");
                }
                clazz.OmaNimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("oma_nimi")).Value;
                goto START;
            oma_eesnimi:
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>vlaevRequest>oma_andmed>oma_eesnimi");
                }
                clazz.OmaEesnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("oma_eesnimi")).Value;
                goto START;
            }
        }
    }
}
